async function* asyncGenerator() {
  console.log("inner 101");
  yield 101;
  console.log("inner 102");
  yield 102;
  console.log("inner 103");
  yield 103;
}

(async function () {
  for await (const num of asyncGenerator()) {
    console.log(num);
  }
})();
// 0
// 1
// 2

const asyncIterable = {
  [Symbol.asyncIterator]() {
    return {
      i: 0,
      next() {
        if (this.i < 3) {
          return Promise.resolve({ value: this.i++, done: false });
        }

        return Promise.resolve({ value: 99999, done: true });
      },
    };
  },
};

(async function () {
  for await (const num of asyncIterable) {
    console.log(num);
  }
})();

// 0
// 1
// 2
